<script>
function salvarNome()
{
	var nome = $("#elm_avulc").val();

	$.post("/cafe/pedido/salvar-nome", {cod: <?php echo $this->res_ped[0]["caf02_cod"]; ?>, caf02_nome_cliente: nome}, function(r){listProd();});
}
</script>

<label id="labelUser" class="labelUser" style="font-weight: bold;"><?php echo $this->res_ped[0]["caf01_user"]; ?></label>
<label style="font-size: 12px; float: right;">
cod. <?php echo $this->res_ped[0]["caf02_cod"]; ?></label>
<br />
<?php echo Data::getDataBR($this->res_ped[0]["caf02_date"].$this->res_ped[0]["caf02_time"]); ?>
<br />
<?php 
if($this->res_ped[0]["caf02_mesa"])
{
?>
<label id="labelTable" style="font-size: 24px;">Mesa <?php echo $this->res_ped[0]["caf02_mesa"]; ?></label>
<label id="labelPax" 
style="font-size: 16px;">
pax <?php echo $this->res_ped[0]["caf02_group"]; ?></label>
<?php 
}
elseif($this->res_ped[0]["caf02_ticket"])
{
?>
<label style="font-size: 24px; padding: 5px 0 5px 0;">
	Ticket N&uacute;mero <strong><?php echo $this->res_ped[0]["caf02_ticket"]; ?></strong>
</label>
<?php 
}else{
?>
	<?php if(!$this->res_ped[0]["caf02_nome_cliente"])
		$var_nome = "Pedido Avul&ccedil;o sem Nome";
	else
		$var_nome = $this->res_ped[0]["caf02_nome_cliente"];
	?>
<label style="font-size: 24px;">
	<input type="text" class="ui-corner-all" 
	style="font-size: 18px; font-weight: bold; 
	padding: 3px; padding-left: 0; color: blue; border: 0;text-decoration: underline; 
	background: transparent;" id="elm_avulc" onclick="$('#salvar_nome').fadeIn(); this.value=''; showKeyboard('elm_avulc');"
	value="<?php echo $var_nome; ?>" />
	<div id="salvar_nome" style="font-size: 12px; display: none; margin-top: 7px;">
	<a href="javascript:;" class="ui-corner-all" 
	style="font-size: 16px; font-weight: bold; 
	padding: 3px; border: 1px solid gray; 
	background: white;" onclick="salvarNome();">
	Salvar
	</a>
	</div>
</label>
<?php 
}
?>
<hr style="margin: 5px 0 5px 0;" />

<table width="100%" style="font-size: 12px;" cellspacing="0" cellpadding="0">
	<?php 
	
	$total_geral = 0;
	$auxMenu = 0;
	
	error_reporting(0);
	
	if(!$this->arr_pedido){
		echo "<tr><td><i>Nenhum produto adicionado.</i><td><tr>";
	}else{
		
	?>
		<script>var itens_pedido = true;</script>
	<?php 
	}
	
	foreach ($this->arr_pedido as $key => $val)
	{
		$total_prod  = $val["caf05_valor"] * $val["caf04_qtd"];
		$total_geral += $total_prod;
		$id_item = $_POST["cod_item"];
		
		if($auxMenu != $val['caf05_cod_menu'] && $auxMenu)
		{
			echo "<tr><td colspan='4'><div style='height: 5px;'></div></td></tr>";
		}
	?>
	<tr <?php if($id_item ==  $val["caf05_cod"]): ?> style="font-weight: bold; font-size: 11px;" <?php endif; ?> >
		<td width="1%" valign="top">
			<?php echo $val["caf04_qtd"]; ?>&nbsp;
		</td>
		<td>
			<?php echo "{$val["caf05_prod"]}({$val["caf05_car"]})"; ?>
		</td>
		<td width="1%" valign="top">
			R$<?php echo Num::money($total_prod); ?>	
		</td>
	</tr>
	<?php if($val["caf04_coment"]){?>
	<tr>
		<td colspan="4">
			<div style="margin-left: 10px; text-align: justify;"><i><?php echo $val["caf04_coment"]; ?></i></div>	
		</td>
	</tr>
	<?php }?>
	<?
		$auxMenu = $val['caf05_cod_menu'];
	}
	
	?>
</table>
<hr style="margin: 5px 0 5px 0" />
<div style="float: left; font-size: 12px;">
	Total
</div>
<div style="text-align: right; font-size: 12px;">
	R$<?php echo Num::money($total_geral - $this->res_ped[0]['caf02_desconto']); ?>
</div>
<?php if($this->res_ped[0]['caf02_desconto']){?>
<hr style="margin: 5px 0 5px 0" />
<div style="color: red;">
	<div style="font-size: 10px;">
		*Desconto de R$<?php echo Num::money($this->res_ped[0]['caf02_desconto']); ?>
	</div>
</div>
<?php }?>